

use  "${data}ACS2017-2021_finalready.dta"   , clear 



***********************************************************************************************************************	*						
* TABLE 2 : MAIN ORIGIN COUNTRY 
************************************************************************************************************************			

	
	* ONLY  Mexico, India, China Philippines Philippines, MiddleEast N.Afri   
            
	replace country_ori=. if country_ori>=6 
											
	
	*BY MAIN ORIGIN COUNTRY and GENDER
		
		global dependent   agemig_p50_bygender masterdegree bachelordegree   expandedmarstat1   ///
						    status_evermarried1 status_evermarried2 status_evermarried3 
						
		
		foreach v in   masterdegree bachelordegree highschool  expandedmarstat1 ///
					 status_evermarried1 status_evermarried2 status_evermarried3 {
			replace `v'=`v'*100
		}
		
	 
	
	quietly levelsof country_ori
		foreach value in `r(levels)' {
			local countrylabel: label( country_ori) `value' 
		
		qui eststo  desc_M_`value'  : estpost tabstat  $dependent  if country_ori==`value' & male==1 , statistics(n mean    ) columns(statistics) 	
		qui eststo  desc_F_`value'  : estpost tabstat  $dependent  if country_ori==`value' & male==0 , statistics(n mean    ) columns(statistics) 	
	
	}	
	
	nois esttab desc_M_1  desc_M_2  desc_M_3 desc_M_4  desc_M_5     , label replace  cells( `"mean( fmt(1) pattern(1 ) )"' `""' )  varwidth(40) ///
	mtitles("Mexico" "India" "China" "Philippines" "MENA" ) title(Table 2: Panel A (Men))
	
	nois esttab desc_M_1  desc_M_2  desc_M_3 desc_M_4  desc_M_5   using "${result}Table2_Panel_A.smcl"   , label replace  cells( `"mean( fmt(1) pattern(1 ) )"' `""' )  		varwidth(40) mtitles("Mexico" "India" "China" "Philippines" "MENA" ) title(Table 2: Panel A (Men))
	
	nois esttab desc_F_1  desc_F_2  desc_F_3 desc_F_4  desc_F_5     , label replace  cells( `"mean( fmt(1) pattern(1 ) )"' `""' )  varwidth(40) ///
	mtitles("Mexico" "India" "China" "Philippines" "MENA" ) title(Table 2: Panel B (Women))
	
	nois esttab desc_F_1  desc_F_2  desc_F_3 desc_F_4  desc_F_5   using "${result}Table2_Panel_B.smcl"    , label replace  cells( `"mean( fmt(1) pattern(1 ) )"' `""' )  varwidth(40) mtitles("Mexico" "India" "China" "Philippines" "MENA" ) title(Table 2: Panel B (Women))
	
	
